import allure
from page_object.page_roncoo_pay_login import PageLogin
from page_element.el_Roncoo import *
import logging



class AddUserName(PageLogin):
    """首页搜索商品后退出登录"""

    def page_add_username(self, name, phone, password):
        # 前置条件：已登录
        self.page_login('admin', '123456')
        with allure.step("点击用户管理"):
            self.click(user_manage.user_manage)
        with allure.step("点击用户信息"):
            self.click(user_manage.user_info)
        with allure.step("点击添加用户按钮"):
            self.click(user_manage.add_user_btn)
        with allure.step("输入用户名称"):
            self.send_keys(user_manage.userName_inp, name)
        with allure.step("输入手机号"):
            self.send_keys(user_manage.userphone_inp, phone)
        with allure.step("输入登录密码"):
            self.send_keys(user_manage.userpassword_inp, password)
        with allure.step("点击提交"):
            self.click(user_manage.tj_btn)

        # 断言
        with allure.step("验证新增的用户名"):
            dy = self.text(user_manage.dy_userName_text)
            assert '刘北' in dy, '断言失败(添加用户失败)'
            print(f'断言的内容:刘北-在-{dy}')
            logging.info(f'断言的内容:刘北-在-{dy}')





